package com.aegean.MonitorExamSYS.center.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Controller("ClearSessionForMonitor")
@Scope("prototype")
public class ClearSessionForMonitor extends ActionSupport implements
		ServletRequestAware {
	private HttpServletRequest request;
	private HttpSession session;
	private boolean success;

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		try {
			String[] deleteSession = { "confirmConductionsMap",// 删除考点考场的分配
					"MonitorsForMonitorApply",// 删除每个考试单位的监考人员信息
					"SelectPositionForMontior"};// 删除该考试对应的所有考场资格信息
			for (String string : deleteSession) {
				if (session.getAttribute(string) == null) {
					continue;
				} else {
					session.removeAttribute(string);
				}
			}
			success = true;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			success = false;
		}
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
		this.session = request.getSession();

	}

}
